import { Component } from 'vue';

export interface FormItem {
  label: string;
  field: string;
  componentName?: string; // 组件类型
  formItemProps?: object; // 透传给子组件的props
  componentProps?: object; // 透传给子组件的props
}

// 定义异步组件的类型
type AsyncComponent = () => Promise<Component>;

// 定义接口 A
export interface ComponentCfg {
  [key: string]: AsyncComponent;
}

// 默认支持的组件
export const createDefaultComponents = () => {
  return {
    input: () => import('@/common/components/query-form/component/input.vue'),
    inputNumber: () =>
      import('@/common/components/query-form/component/inputNumber.vue'),
    inputRange: () =>
      import('@/common/components/query-form/component/inputRange.vue'),
    select: () => import('@/common/components/query-form/component/select.vue'),
    timePicker: () =>
      import('@/common/components/query-form/component/timePicker.vue'),
    datePicker: () =>
      import('@/common/components/query-form/component/datePicker.vue'),
    rangPicker: () =>
      import('@/common/components/query-form/component/rangPicker.vue'),
    dictSelect: () => import('@/common/components/dict-select/index.vue'),
    inputModal: () =>
      import('@/common/components/search-modal/input-modal.vue'),
    dateRangPicker: () =>
      import('@/common/components/query-form/component/dateRangPicker.vue'),
  };
};
